package com.example.eos.controller;

import com.example.eos.bean.Reply;
import com.example.eos.bean.ReturnInfo;
import com.example.eos.service.ReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class ReplyController {

    private ReplyService replyService;

    @Autowired
    public ReplyController(ReplyService replyService){
        this.replyService = replyService;
    }

    //查看回复
    @RequestMapping(value = "/reply/{replyid}",method = RequestMethod.GET)
    public ReturnInfo getReply(@PathVariable String replyid){
        return replyService.getReply(replyid);
    }

    //查看回复列表
    @RequestMapping(value = "/replys/{commentid}",method = RequestMethod.GET)
    public ReturnInfo getReplys(@PathVariable String commentid){
        return replyService.getReplys(commentid);
    }

    //新建回复
    @RequestMapping(value = "/reply",method = RequestMethod.POST)
    public ReturnInfo creatReply(@RequestBody Reply reply){
        return replyService.creatReply(reply);
    }

    //删除回复
    @RequestMapping(value = "/reply/{replyid}",method = RequestMethod.DELETE)
    public ReturnInfo deleteReply(@PathVariable String replyid){
        return replyService.deleteReply(replyid);
    }

}
